package com.wft.面试题;

public class finallyAndResturn {
    public static void main(String[] args) {
        System.out.println("function1 ==> " + function1());
        System.out.println("function2 ==> " + function2().x);
    }

    public static int function1(){
        int i = 1;
        try {
            return i;
        } finally {
            ++i;
        }
    }

    public static Data function2(){
        Data data = new Data();
        data.x = 1;
        try {
            return data;
        } finally {
            ++data.x;
        }
    }

    public static class Data{
        public int x = 0;
    }
}
